// Package passenger 模型
package passenger

import (
	// "gitee.com/sweetsunnyflower/carpooling-server-go/pkg/logger"
	"gitee.com/sweetsunnyflower/carpooling-server-go/app/models"
	"gitee.com/sweetsunnyflower/carpooling-server-go/pkg/database"
)

type Passenger struct {
	models.BaseModel
	UserId       uint64  `gorm:"column:user_id" db:"user_id" json:"user_id" form:"user_id"`
	Balance      float64 `gorm:"column:balance" db:"balance" json:"balance" form:"balance"`                                        //账号余额
	Trip         int     `gorm:"column:trip" db:"trip" json:"trip" form:"trip"`                                                    //出行次数
	Comments     int     `gorm:"column:comments" db:"comments" json:"comments" form:"comments"`                                    //评论数
	FollowsCount int64   `gorm:"column:follows_count;comment:关注司机数;" db:"follows_count" json:"follows_count" form:"follows_count"` //评论数
	BlacksCount  int64   `gorm:"default:0;column:blacks_count;comment:拉黑司机数;" db:"blacks_count" json:"blacks_count" form:"blacks_count"`

	models.CommonTimestampsField
}

func (passenger *Passenger) Create() {
	database.DB.Create(&passenger)
}

func (passenger *Passenger) Save() (rowsAffected int64) {
	result := database.DB.Save(&passenger)
	return result.RowsAffected
}

func (passenger *Passenger) Delete() (rowsAffected int64) {
	result := database.DB.Delete(&passenger)
	return result.RowsAffected
}
